/*
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-06-01 12:05:10
 * @LastEditors: voanit
 * @LastEditTime: 2022-06-08 09:51:03
 */
import { ChannelAction } from '@/types/store'
import { Channel } from '@/types/data'
const initialState: {
  userChannels: Channel[],
  activeIndex: string,
  allChannels: Channel[]
} = {
  userChannels: [
  ],
  activeIndex: '0',
  allChannels: []
}
const channel = (state = initialState, action: ChannelAction) => {
  // console.log(action, 223);

  switch (action.type) {
    case 'channel/saveUserChannels':
      return { ...state, userChannels: action.payload }
    case 'channel/changeActive':
      return { ...state, activeIndex: action.payload }
    case 'channel/saveAllChannels':
      return { ...state, allChannels: action.payload }
    default:
      return state
  }
}

export default channel